var minCostClimbingStairs = function(cost) {
  // 使用动态规划求解，设置dp[0] 为走一个台阶 dp[1]走两个台阶
  let dp= [];
  let n = cost.length;
  dp[0] = cost[0];
  dp[1] = cost[1];
  for(let i=2;i<n;i++){
    dp[i] = Math.min(dp[i-1], dp[i-2])+cost[i] ;
    console.log(dp[i]);
  }
  return Math.min(dp[n-1],dp[n-2]);
};


console.log(minCostClimbingStairs([1,23,45,2,1,3,5]));